package com.linghui.videoplus.ipai.adapter;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.linghui.videoplus.ipai.R;
import com.linghui.videoplus.ipai.bean.MessageBean;

public class MessageBoxAdapter extends BaseAdapter {

	private LayoutInflater inflater = null;
	private Context mContext = null;
	List<MessageBean> list=new ArrayList<MessageBean>();

	public MessageBoxAdapter(Context context,List<MessageBean> list) {
		this.mContext = context;
		this.list=list;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		final ViewHolder viewHolder;
		MessageBean messageBean=(MessageBean)list.get(position);
		if (convertView == null) {
			if (inflater == null) {
				inflater = (LayoutInflater) mContext
						.getSystemService(mContext.LAYOUT_INFLATER_SERVICE);
			}
			convertView = inflater.inflate(R.layout.adapter_message, null);
			viewHolder = new ViewHolder();
			viewHolder.msgStatusImageView=(ImageView) convertView.findViewById(R.id.msgIconImageView);
			viewHolder.msgReplyImageView=(ImageView) convertView.findViewById(R.id.msgReplyImageView);
			viewHolder.msgDescTextView=(TextView)convertView.findViewById(R.id.msgDescTextView);
			convertView.setTag(viewHolder);
		} else {
			viewHolder = (ViewHolder) convertView.getTag();
		}
		viewHolder.msgDescTextView.setText(messageBean.getDescribe());
		return convertView;
	}

	@Override
	public int getCount() {
		return list.size();
	}

	@Override
	public Object getItem(int arg0) {
		return list.get(arg0);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	class ViewHolder {
		ImageView msgStatusImageView;
		ImageView msgReplyImageView;
		TextView msgTitleTextView;
		TextView msgDescTextView;
		TextView msgCreadDateTextView;
	}

}
